#ifndef __SUBSYSTEM_TIME_OF_DAY_H__
#define __SUBSYSTEM_TIME_OF_DAY_H__

#include "Subsystem.hpp"

namespace PocketSurvival
{
    class SubsystemGameInfo;

    class SubsystemTimeOfDay : public Subsystem
    {
    protected:
        SubsystemGameInfo *m_gameInfo;

        double m_gameTime = 0;
        float m_gameTimeDelta = 0.0f;

    public:
        
        bool periodicGameTimeEvent(double period, double offset);

        float getTimeOfDay();
        double getDay();
        
        inline double getGameTime();
        inline float getGameTimeDelta();

    public:
        SubsystemTimeOfDay();

        virtual void update(float dt) override;
        virtual void load(const nlohmann::json& json) override;
        virtual void save(nlohmann::json& json) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;

        virtual const std::string& getName() const override;
        virtual SubUpdateType getUpdateType() override;

    public:
        // 游戏内的日常时间（白天和夜晚）
        double timeOfDayOffset;
    };

    inline SubsystemTimeOfDay::SubsystemTimeOfDay() {}
    inline double SubsystemTimeOfDay::getGameTime()
    {
        return m_gameTime;
    }
    inline float SubsystemTimeOfDay::getGameTimeDelta()
    {
        return m_gameTimeDelta;
    }
}

#endif